<!--我的消息-->
<template>
  <div class="app-container">
    <div class="filter-container">
      <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
        <el-tab-pane v-for="item in tabMapOptions" :key="item.key" :label="item.label" :name="item.key">
          <div class="filter-container">
            <el-button style="margin-right: 10px" class="filter-item" type="primary">全部已读</el-button>
            <el-button style="margin-right: 10px" class="filter-item">批量处理</el-button>
          </div>
          <div class="msg-content">
            <el-checkbox-group v-model="message">
            <div class="msg-box">
                <!--<el-checkbox-group>-->
                  <!--<el-checkbox>1-->
                  <!--</el-checkbox>-->
                <!--</el-checkbox-group>-->
              <el-checkbox class="check-box"></el-checkbox>
              <img src="../../../../public/image/msg-icon.png" class="msg-img"/>
              <div class="msg-text">
                <div><span class="un-reader">•</span>批量处理批量处理批量处理批量处理批量处理批量处理批量处理批量处理批量处理</div>
                <div class="date-text">2021-05-07 16:20:10</div>
              </div>

            </div>
              <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
            </el-checkbox-group>
          </div>
          <div class="table-pagination">
            <ve-pagination
              :total="totalCount"
              :page-index="pageIndex"
              :page-size="pageSize"
              @on-page-number-change="pageNumberChange"
              @on-page-size-change="pageSizeChange"
            />
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<style scoped lang="scss">
  .table-pagination {
    margin-top: 20px;
    text-align: right;
  }
  .right-btn{
    float: right;
  }
  .msg-content{
    width: 100%;
    margin: 0 auto;
    .msg-box{
      width: 100%;
      border: 1px solid #DBDBDB;
      margin: 10px auto;
      padding: 10px;
      display: flex;
      .check-box{
        line-height: 48px;
        padding: 0 10px;
      }
      .msg-img{
        width: 48px;
        height: 48px;
      }
      .msg-text{
        font-size: 14px;
        color: #333333;
        line-height: 20px;
        padding-left: 10px;
        overflow: hidden;
        overflow-wrap: break-word;
        .un-reader{
          color: #FF4444;
          font-size: 18px;
          margin: 0 2px;
        }
        .date-text{
          font-size: 13px;
          color: #808080;
        }
      }
    }
  }
</style>

<script>

  export default {
    data() {
      return {
        // page index
        isIndeterminate: true,
        checkAll: false,
        message: null,
        pageIndex: 1,
        dataTable: [],
        totalCount: '',
        tableData: [],
        // page size
        pageSize: 10,
        listQuery: {},
        rowStyleOption: { // 表格样式
          stripe: true, // 斑马纹
          hoverHighlight: true, // hover高亮
          clickHighlight: true // 点击行高亮
        },
        msgNum: '',
        unReMsg: '',
        activeName: 'AllMessage',
        tabMapOptions: [
          {
            label: '全部消息',
            key: 'AllMessage'
          },
          {
            label: '未读消息',
            key: 'UnReadMsg'
          }
        ],
        checkboxOptipon: {
          // 行选择改变事件
          selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
            console.log(row, isSelected, selectedRowKeys)
          },
          // 全选改变事件
          selectedAllChange: ({ isSelected, selectedRowKeys }) => {
            console.log(isSelected, selectedRowKeys)
          }
        },
        columns: [
          {
            field: '',
            key: 'z',
            // type=checkbox
            type: 'checkbox',
            title: '',
            width: 50,
            align: 'center'
          }
        ],
        notColumn: [
          {
            field: '',
            key: 'z',
            // type=checkbox
            type: 'checkbox',
            title: '',
            width: 50,
            align: 'center'
          },
          {
            field: '',
            key: 'a',
            title: '序号',
            align: 'center',
            renderBodyCell: ({ row, column, rowIndex }, h) => {
              return (this.pageIndex - 1) * this.pageSize + rowIndex + 1
            }
          },
          { field: 'name', key: 'b', title: '订单编号', align: 'center', width: '100px' },
          { field: 'name', key: 'c', title: 'GPS订单编号', align: 'center', width: '100px' },
          { field: 'date', key: 'd', title: '客户姓名', align: 'left', width: '100px' },
          { field: 'address', key: 'e', title: '部门', width: '' },
          { field: 'address', key: 'f', title: '业务员', width: '' },
          { field: 'address', key: 'g', title: '贷款金额', width: '' },
          { field: 'address', key: 'l', title: '贷款银行', width: '' }
        ],
        freeColumns: [
          {
            field: '',
            key: 'z',
            // type=checkbox
            type: 'checkbox',
            title: '',
            width: 50,
            align: 'center'
          },
          {
            field: '',
            key: 'a',
            title: '序号',
            align: 'center',
            renderBodyCell: ({ row, column, rowIndex }, h) => {
              return (this.pageIndex - 1) * this.pageSize + rowIndex + 1
            }
          },
          { field: 'name', key: 'b', title: '订单编号', align: 'center', width: '100px' },
          { field: 'name', key: 'c', title: 'GPS订单编号', align: 'center', width: '100px' },
          { field: 'date', key: 'd', title: '客户姓名', align: 'left', width: '100px' },
          { field: 'address', key: 'e', title: '部门', width: '' },
          { field: 'address', key: 'f', title: '业务员', width: '' },
          { field: 'address', key: 'g', title: '贷款金额', width: '' },
          { field: 'address', key: 'h', title: '贷款银行', width: '' },
          { field: 'address', key: 'i', title: '免装备注', width: '' }
        ]
      }
    },
    computed: {
      // table data
      // tableData() {
      //   const { pageIndex, pageSize } = this
      //   return DB_DATA.slice((pageIndex - 1) * pageSize, pageIndex * pageSize)
      // },
      // total count
      // totalCount() {
      //   return this.tableData.length
      // }
    },
    created() {
      this.initDatabase()
    },
    methods: {
      handleCheckAllChange(val) {
        this.isIndeterminate = false;
      },
      // page number change
      pageNumberChange(pageIndex) {
        this.pageIndex = pageIndex
      },

      // page size change
      pageSizeChange(pageSize) {
        this.pageIndex = 1
        this.pageSize = pageSize
      },

      // Simulation table data
      async initDatabase() {
        this.tableData = [];
        let param = {appId:"9999",pageIndex:this.pageIndex,pageSize:this.pageSize};
        let data = await this.$http.get('/auth/distributor/get', param)
        console.log(data);
        if (data.code === 200) {
          this.tableData = data.data;
          this.totalCount = data.data.length;
        } else {

        }


        console.log(this.tableData)




      },
      handleClick () {}
    }
  }
</script>
